<?php
header("content-type:text/html;charset=utf-8");
session_start();

if(isset($_SESSION["u_user"])) {
	include_once('classes/addtime/time.class.php');
    $time = new time();
	if(isset($_POST['submit'])) {
	    if($_POST['project']=='' || $_POST['date']=='' || $_POST['day']=='' || $_POST['month']=='') {
		    echo '<script>alert("更新信息不能为空！");location.href="time.php"</script>';
		}
		$data = array('a_project'=>$_POST['project'],'a_date'=>$_POST['date'],'a_day'=>$_POST['day'],'a_month'=>$_POST['month']);
		$res = $time->update_time($_POST['aid'],$data);
		if($res) {
		    echo '<script>alert("修改成功！");location.href="time.php"</script>';
		} else {
		    echo '<script>alert("修改失败！");location.href="update.php"</script>';
		}
		
	}
	else
	{
	$aid = $_GET['aid'];
    $name = $_SESSION["u_user"];
	$info = $time->get_one_time($aid=$aid);
	
?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8">
        <title>管理</title>
        <meta name="description" content="mobile first, app, web app, responsive, admin dashboard, flat, flat ui">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link rel="stylesheet" href="caches/css/bootstrap.css">
        <link rel="stylesheet" href="caches/css/font-awesome.min.css">
        <link rel="stylesheet" href="caches/css/style.css">
        <link rel="stylesheet" href="caches/css/plugin.css">
        <link rel="stylesheet" href="caches/css/landing.css">
        <!--[if lt IE 9]>
        <script src="caches/js/ie/respond.min.js"></script>
        <script src="caches/js/ie/html5.js"></script>
        <![endif]-->
        <link rel="stylesheet" href="caches/build/kalendae.css" type="text/css" charset="utf-8">
        <!-- <script src="src/moment.js" type="text/javascript" charset="utf-8"></script>
        <script src="build/kalendae.js" type="text/javascript" charset="utf-8"></script> -->
        <script src="caches/build/kalendae.standalone.js" type="text/javascript" charset="utf-8"></script>
        <style type="text/css" media="screen">
            .kalendae .k-days span.closed
            {
                background:red;
            }
        </style>
    </head>
    <body>
    <!-- header -->
    <header id="header" class="navbar">
        <ul class="nav navbar-nav navbar-avatar pull-right">
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    <span class="hidden-sm-only"></span>
                    <span class="thumb-small avatar inline"><img src="caches/images/avatar.jpg" alt="" class="img-circle"></span>
                    <b class="caret hidden-sm-only"></b>
                </a>
                <ul class="dropdown-menu">
                    <li class="icon-gear"><span class="text"><a href="#">设置</a></span></li>
                    <li class="divider"></li>
                    <li class="icon-group"><span class="text"><a href="user.php">修改</a></span></li>
                </ul>
            </li>
        </ul>
        <a class="navbar-brand" href="#">管理</a>
        <button type="button" class="btn btn-link pull-left nav-toggle hidden-lg" data-toggle="class:slide-nav slide-nav-left" data-target="body">
            <i class="icon-reorder icon-xlarge text-default"></i>
        </button>
        <ul class="nav navbar-nav hidden-sm">
            <li class="dropdown shift" data-toggle="shift:appendTo" data-target=".nav-primary .nav">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-cog icon-xlarge visible-sm visible-sm-inline"></i>设置<b class="caret hidden-sm-only"></b></a>
                <ul class="dropdown-menu">
                    <li>
                        <a href="#" data-toggle="class:navbar-fixed" data-target='body'>
                            <span class="text-active">自动</span>
                            <span class="text">固定</span>
                        </a>
                    </li>
                    <li class="visible-lg">
                        <a href="#" data-toggle="class:nav-vertical" data-target="#nav">
                            <span class="text-active">垂直</span>
                            <span class="text">水平</span>
                        </a>
                    </li>
                    <li class="divider hidden-sm"></li>
                    <li class="dropdown-header">颜色</li>
                    <li>
                        <a href="#" data-toggle="class:bg bg-black" data-target='.navbar'>上：
                            <span class="text-active">白色</span>
                            <span class="text">黑色</span>
                        </a>
                    </li>
                    <li>
                        <a href="#" data-toggle="class:bg-light" data-target='#nav'>左：
                            <span class="text-active">暗</span>
                            <span class="text">亮</span>
                        </a>
                    </li>
                </ul>
            </li>
        </ul>
    </header>
    <!-- / header -->
    <!-- nav -->
    <nav id="nav" class="nav-primary visible-lg nav-vertical">
        <ul class="nav" data-spy="affix" data-offset-top="50">
            <li class="dropdown-submenu">
                <a href="#"><i class="icon-edit icon-xlarge"></i>加班信息</a>
                <ul class="dropdown-menu">
                    <li><a href="addtime.php">新增</a></li>
                    <li><a href="time.php">编辑</a></li>
                </ul>
            </li>
            <li class="dropdown-submenu">
                <a href="#"><i class="icon-signout icon-xlarge"></i>其他</a>
                <ul class="dropdown-menu">
                    <li><a href="quit.php">注销</a></li>
                </ul>
            </li>
        </ul>
    </nav>
    <!-- / nav -->
			 <section id="content">
            <section class="main padder">
                <div class="clearfix">
                    <h4><i class="icon-edit"></i>加班信息</h4>
                </div>
                <div class="row">
                    <div class="panel">
                        <div class="clearfix">
                            <!-- checkbox -->
                            <form class="form-horizontal" method="post"action="update.php">
								<input type="hidden" name="aid" value="<?php echo $aid;?>">
                                <div class="form-group">
                                    <label for="username" class="col-sm-2 control-label">加班人</label>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control" id="username" value="<?php echo $name; ?>"  name="username">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="project" class="col-sm-2 control-label">加班项目</label>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control" id="project" placeholder="project" name="project">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="month" class="col-sm-2 control-label">加班月份</label>
                                    <div class="col-sm-2">
                                        <select class="form-control" name="month" type="month" placeholder="加班月份">
                                            <option>1</option>
                                            <option>2</option>
                                            <option>3</option>
                                            <option>4</option>
                                            <option>5</option>
                                            <option>6</option>
                                            <option>7</option>
                                            <option>8</option>
                                            <option>9</option>
                                            <option>10</option>
                                            <option>11</option>
                                            <option>12</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="date" class="col-sm-2 control-label">加班日期</label>
                                    <div class="col-sm-2">
                                        <input type="text"  placeholder="date" value=""  name="date" id="date">
                                        <script type="text/javascript" size="16">
                                            var intput = new Kalendae.Input('date',{
                                                mouths:1,
                                                mode:'multiple',
                                                //selected:[Kalendae.moment().subtract({M:1}), Kalendae.moment().add({M:1})]
                                            });
                                        </script>
                                    </div>
                                </div>
                                <div class="form-group"><label for="day" class="col-sm-2 control-label">加班天数</label>
                                    <div id="MySpinner" class="spinner input-group m-b col-sm-2">
                                        <input type="text" class="input-small spinner-input form-control" placeholder="day" name="day" maxlength="3">
                                       <div class="btn-group btn-group-vertical input-group-btn">
                                            <button type="button" class="btn btn-white spinner-up form-control">
                                                <i class="icon-chevron-up"></i>
                                            </button>
                                            <button type="button" class="btn btn-white spinner-down form-control">
                                                <i class="icon-chevron-down"></i>
                                            </button>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-2 control-label">
                                        <input type="submit" id="submit" name="submit" class="btn btn-default" value="提交">
                                    </div>
								</div>
					        </form>
						</div>
					</div>
				</div>
            </section>
        </section>
    <footer id="footer">
        <div class="text-center padder clearfix">
            <p>
                <small>&copy;山东舜网传媒股份有限公司</small><br><br>
            </p>
        </div>

    </footer>
    <!-- / footer -->
    <script src="caches/js/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="caches/js/bootstrap.js"></script>
    <!-- app -->
    <script src="caches/js/app.js"></script>
    <script src="caches/js/app.plugin.js"></script>
    <script src="caches/js/app.data.js"></script>
    <!-- fuelux -->
    <script src="caches/js/fuelux/fuelux.js"></script>
    <!-- datepicker -->
    <script src="caches/js/datepicker/bootstrap-datepicker.js"></script>
    <!-- slider -->
    <script src="caches/js/slider/bootstrap-slider.js"></script>
    <!-- file input -->
    <script src="caches/js/file-input/bootstrap.file-input.js"></script>
    <!-- combodate -->
    <script src="caches/js/combodate/moment.min.js"></script>
    <script src="caches/js/combodate/combodate.js"></script>
    <!-- parsley -->
    <script src="caches/js/parsley/parsley.min.js"></script>
    <script type="text/javascript" charset="utf-8">
        var intput = new Kalendae.Input('date',{
            mouths:1,
            mode:'multiple',
            selected:[Kalendae.moment().subtract({M:1}), Kalendae.moment().add({M:1})]
        });
    </script>
</body>
</html>
<?php 
}}
else
{
	echo '<script>alert("请先登录");location.href="login.php";</script>';
}
?>